home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 136_01.zip / RDTERM.C < prev    next >
Text File  |  1993-06-01  |  3KB  |  164 lines

  1. /*    HEADER:  CUG136.12;
  2.     TITLE:        RDTERM;
  3.     VERSION:    1.00;
  4.     DATE:        11/1/1983;
  5.     DESCRIPTION:    "Terminal installation checkout program";
  6.     KEYWORDS:    terminal interface,installation,configuration;
  7.     SYSTEM:        CP/M;
  8.     FILENAME:    RDTERM.C;
  9.     AUTHORS:    R. Rodman;
  10.     COMPILERS:    C/80;
  11. */
  12.  
  13. /* Program to read the TERMINAL.SYS file
  14.     831101 rr convert to C 1.003 */
  15.  
  16. char trmbuf[ 128 ];
  17. char *p;
  18. int i;
  19.  
  20. int width, height, defint, uselst, yfirst, method, addx, addy;
  21. char *inistr, *clrscn, *clreos, *clreol, *curoff, *curon,
  22.     *curbeg, *curmid, *curend, *hiint, *loint, *revvid, *norvid,
  23.     *inslin, *dellin;
  24.  
  25. main()
  26. {
  27.     puts( "Terminal Test Program v.1.003\n" );
  28.  
  29.     term_init();
  30.  
  31.     /* Begin testing of terminal */
  32.  
  33.     puts( "Clear screen: should not appear." );
  34.     puts( clrscn );
  35.  
  36.     goxy( width - 18, 0 );
  37.     puts( "Goxy: Upper Right" );
  38.  
  39.     goxy( 0, height - 1 );
  40.     puts( "Delete line: Center" );
  41.     goxy( 15, height / 2 + 2 );
  42.     puts( "Delete line: should not appear." );
  43.     goxy( 0, height / 2 );
  44.     for( i = 1; i <= height / 2 - 1; i++ ) puts( dellin );
  45.  
  46.     goxy( width - 26, height / 2 + 1 );
  47.     puts( "Insert line: Bottom Right" );
  48.     goxy( 0, height / 2 + 1 );
  49.     for( i = 1; i <= 10; i++ ) puts( inslin );
  50.  
  51.     goxy( 5, 4 );
  52.     puts( revvid );
  53.     puts( "Reverse Video" );
  54.     puts( norvid );
  55.  
  56.     goxy( 30, 4 );
  57.     puts( loint );
  58.     puts( "Low Intensity" );
  59.  
  60.     goxy( 30, 5 );
  61.     puts( hiint );
  62.     puts( "High Intensity" );
  63.  
  64.     if( defint != 'H' ) puts( loint );
  65.  
  66.     goxy( 0, height - 1 );
  67.     puts( "Press RETURN: " );
  68.     i = getchar();
  69.     exit();
  70. }
  71.  
  72. term_init()
  73. {
  74.     int t, u;
  75.     char *p;
  76.     t = fopen( "TERMINAL.SYS", "r" );
  77.  
  78.     if( t == 0 ) {
  79.         puts( "Run TERMINAL first, please." );
  80.         exit();
  81.     }
  82.  
  83.     p = &trmbuf[ 0 ];
  84.  
  85.     read( t, p, 128 );
  86.  
  87.     fclose( t );
  88.  
  89.     width = *p++;
  90.     height = *p++;
  91.     defint = *p++;
  92.     uselst = *p++;
  93.     yfirst = *p++;
  94.     method = *p++;
  95.     addx = *p++;
  96.     addy = *p++;
  97.  
  98.     for( u = 1; u <= 15; u++ ) {
  99.         switch( u ) {
  100.             case 1 : inistr = p; break;
  101.             case 2 : clrscn = p; break;
  102.             case 3 : clreos = p; break;
  103.             case 4 : clreol = p; break;
  104.             case 5 : curoff = p; break;
  105.             case 6 : curon = p; break;
  106.             case 7 : curbeg = p; break;
  107.             case 8 : curmid = p; break;
  108.             case 9 : curend = p; break;
  109.             case 10 : hiint = p; break;
  110.             case 11 : loint = p; break;
  111.             case 12 : revvid = p; break;
  112.             case 13 : norvid = p; break;
  113.             case 14 : inslin = p; break;
  114.             case 15 : dellin = p; break;
  115.         }
  116.  
  117.         p++; p++; p++; p++;
  118.         p++; p++; p++; p++;
  119.     }
  120. }
  121.  
  122.     /* output a coordinate */
  123.  
  124. coord( c )
  125. int c;
  126. {
  127.     switch( method ) {
  128.         case '0' : putchar( c ); break;
  129.         case '1' : {
  130.             if( c >= 100 ) {
  131.                 putchar( '0' + c / 100 );
  132.                 c %= 100;
  133.             }
  134.             if( c >= 10 ) {
  135.                 putchar( '0' + c / 10 );
  136.                 c %= 10;
  137.             }
  138.             putchar( '0' + c );
  139.         }
  140.     }
  141. }
  142.  
  143.     /* position cursor */
  144.  
  145. goxy( x, y )
  146. int x, y;
  147. {
  148.     puts( curbeg );
  149.     if( yfirst == 'Y' ) coord( y + addy );
  150.         else coord( x + addx );
  151.     puts( curmid );
  152.     if( yfirst == 'Y' ) coord( x + addx );
  153.         else coord( y + addy );
  154.     puts( curend );
  155. }
  156.  
  157. puts( p )
  158. char *p;
  159. {
  160.     while( *p ) putchar( *p++ );
  161. }
  162.  
  163.  
  164.